package com.example.smartcity.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.smartcity.R;
import com.example.smartcity.activity.ApartmentIllegalComplaint;
import com.example.smartcity.activity.GarbageClassificationActivity;
import com.example.smartcity.activity.SupervisionIllegalActivity;
import com.example.smartcity.activity.WebViewActivity;


public class ServiceFragment extends BaseFragment implements View.OnClickListener {
    private static final String TAG = ServiceFragment.class.getSimpleName();
    private TextView tv_garbage_classification;
    private TextView supervision_of_illegal_activities;
    private TextView apartment_illegal_complaint,environment;
    private Intent intent;



    @SuppressLint("HandlerLeak")
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);


        }
    };

    @Override
    public View initView() {
        Log.i(TAG, "服务的视图被初始化了");
        View view = View.inflate(getContext(), R.layout.fragment_service, null);
        tv_garbage_classification = view.findViewById(R.id.tv_garbage_classification);
        supervision_of_illegal_activities = view.findViewById(R.id.tv_supervision_of_illegal_activities);
        apartment_illegal_complaint = view.findViewById(R.id.tv_apartment_illegal_complaint);
        environment = view.findViewById(R.id.environment);
        environment.setOnClickListener(this);
        tv_garbage_classification.setOnClickListener(this);
        supervision_of_illegal_activities.setOnClickListener(this);
        apartment_illegal_complaint.setOnClickListener(this);
        return view;
    }


    @Override
    public void initData() {
        super.initData();


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_garbage_classification:
                intent = new Intent(getActivity(), GarbageClassificationActivity.class);
                getActivity().startActivity(intent);
                break;
            case R.id.tv_supervision_of_illegal_activities:
                intent = new Intent(getActivity(), SupervisionIllegalActivity.class);
                getActivity().startActivity(intent);
                break;
            case R.id.tv_apartment_illegal_complaint:
                intent = new Intent(getActivity(), ApartmentIllegalComplaint.class);
                getActivity().startActivity(intent);
                break;
            case R.id.environment:
                Intent intent = new Intent(getContext(), WebViewActivity.class);
                intent.putExtra("url","https://www.air-level.com/air/shijiazhuang/");
                getActivity().startActivity(intent);
                break;

        }
    }
}
